home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / BORLAND TURBO / BATCH.PAK / BATCHVW.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  3.8 KB  |  159 lines

  1. /**************************************************************************
  2.  *
  3.  *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4.  *  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5.  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6.  *  PURPOSE.
  7.  *
  8.  *  Copyright (c) 1994 - 1995    Microsoft Corporation.    All Rights Reserved.
  9.  *
  10.  **************************************************************************/
  11. // batchvw.cpp : implementation of the CBatchView class
  12. //
  13.  
  14. #define INC_OLE2
  15. #include "stdafx.h"
  16. #include "windowsx.h"
  17. #include "batch.h"
  18. #include "batchdoc.h"
  19. #include "batchvw.h"
  20.  
  21. #ifdef _DEBUG
  22. #undef THIS_FILE
  23. static char BASED_CODE THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CBatchView
  28.  
  29. IMPLEMENT_DYNCREATE(CBatchView, CView)
  30.  
  31. BEGIN_MESSAGE_MAP(CBatchView, CView)
  32.     //{{AFX_MSG_MAP(CBatchView)
  33.     ON_WM_DROPFILES()
  34.     ON_WM_SIZE()
  35.     //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CBatchView construction/destruction
  40.  
  41. CBatchView::CBatchView()
  42. {
  43.     // TODO: add construction code here
  44. }
  45.  
  46. CBatchView::~CBatchView()
  47. {
  48. }
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CBatchView drawing
  52. void CBatchView::OnDraw(CDC *pDc)
  53. {
  54. }
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CBatchView diagnostics
  58.  
  59. #ifdef _DEBUG
  60. void CBatchView::AssertValid() const
  61. {
  62.     CView::AssertValid();
  63. }
  64.  
  65. void CBatchView::Dump(CDumpContext& dc) const
  66. {
  67.     CView::Dump(dc);
  68. }
  69.  
  70. CBatchDoc* CBatchView::GetDocument() // non-debug version is inline
  71. {
  72.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBatchDoc)));
  73.     return (CBatchDoc*)m_pDocument;
  74. }
  75. #endif //_DEBUG
  76.  
  77. //
  78. // Size ourself, and then size our listbox to snugly fit inside.
  79. //
  80. void CBatchView::OnSize(UINT nType, int cx, int cy)
  81. {
  82.     CBatchDoc* pDoc = GetDocument();
  83.     ASSERT_VALID(pDoc);
  84.     
  85.     CView::OnSize(nType, cx, cy);
  86.     if (pDoc->ListBox.m_hWnd)
  87.         pDoc->ListBox.MoveWindow(0, 0, cx, cy);
  88. }
  89.  
  90. //
  91. // Somebody has dropped a filename on us.  Add it to our list.
  92. //
  93. void CBatchView::OnDropFiles(HDROP hDropInfo) 
  94. {
  95.     CBatchDoc* pDoc = GetDocument();
  96.     ASSERT_VALID(pDoc);
  97.  
  98.     // TODO: Add your message handler code here and/or call default
  99.     
  100.     SetActiveWindow();      // activate us first !
  101.     UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
  102.  
  103.     for (UINT iFile = 0; iFile < nFiles; iFile++)
  104.     {
  105.         TCHAR szFileName[_MAX_PATH];
  106.         ::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);
  107.         pDoc->FileList.AddTail(szFileName);
  108.     }
  109.     ::DragFinish(hDropInfo);
  110.     pDoc->FixListBox();
  111.     Invalidate();
  112. }
  113.  
  114. //
  115. // Brand new window.  Create a listbox for it, which contains all the text we'll
  116. // print.
  117. //
  118. void CBatchView::OnInitialUpdate() 
  119. {
  120.     CBatchDoc* pDoc = GetDocument();
  121.     ASSERT_VALID(pDoc);
  122.     RECT rc;
  123.     
  124.     CView::OnInitialUpdate();
  125.     DragAcceptFiles();
  126.     GetClientRect(&rc);
  127.     pDoc->ListBox.Create(LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL |
  128.         LBS_MULTIPLESEL | LBS_HASSTRINGS | LBS_WANTKEYBOARDINPUT |
  129.         WS_VISIBLE | WS_CHILD | WS_VSCROLL, rc, this, 42);
  130.     pDoc->FixListBox();
  131.  
  132. }
  133.  
  134.  
  135. BOOL CBatchView::OnCommand(WPARAM wParam, LPARAM lParam) 
  136. {
  137.     // TODO: Add your specialized code here and/or call the base class
  138.     
  139.     return CView::OnCommand(wParam, lParam);
  140. }
  141.  
  142. LRESULT CBatchView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
  143. {
  144.     CBatchDoc* pDoc;
  145.     
  146.     switch(message) {
  147.         case WM_VKEYTOITEM:
  148.             switch (LOWORD(wParam)) {
  149.  
  150.                 // Delete the selection
  151.                 case VK_DELETE:
  152.                     pDoc = GetDocument();
  153.                     ASSERT_VALID(pDoc);
  154.                     pDoc->DeleteSelection();
  155.             }
  156.     }            
  157.     return CView::WindowProc(message, wParam, lParam);
  158. }
  159.